package in.muton.panels.paginator.components.listitems;

import in.muton.edushare.pages.EduShareBasePage;
import in.muton.edushare.pages.common.EdusharePanel;
import in.muton.panels.paginator.badgehelpers.user.BadgeRoles;
import in.muton.panels.paginator.helpers.RoleChanger;
import in.muton.panels.paginator.helpers.deletelinks.UserRemove;
import in.muton.panels.paginator.helpers.links.UserLink;

import org.apache.wicket.markup.html.CSSPackageResource;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

import com.edushare.common.vo.Users;

public class UserListItem extends EdusharePanel {

	public UserListItem(String id, EduShareBasePage page, final IModel<Users> model,
			final BadgeRoles br) {
		super(id, page);
		add(CSSPackageResource.getHeaderContribution(UserListItem.class, "ListItem.css"));
		add(new UserLink("nameLink", model, "name"));
		add(new Label("role", new Model<String>() {
			private static final long serialVersionUID = 2052369190284168643L;
			@Override
			public String getObject() {
				if (br == null)
					return "";
				String s = br.getRole(model.getObject());
				if(br.isInvited(model.getObject()))
					return "Invited";
				return s;
			}
		}));
		add(new UserRemove("removeLink", model, br, this));
		add(new RoleChanger("roleLV", br, model, this));
	}

	private static final long serialVersionUID = -3502548853009662274L;
}
